//
// Created by cljh on 2023/3/28.
//

#ifndef BIN_PACKING_POINT_H
#define BIN_PACKING_POINT_H

#include <cmath>
#include <cfloat>
#define EPS (1e-5)

class Point{
public:
    double x;
    double y;
    bool mark;
    Point *begin,*end;
    Point(double x=0,double y=0):x(x),y(y),mark(false){
        begin= this;
        end= this;
    }
    Point( const Point &point){
        this->x=point.x;
        this->y=point.y;
        this->mark= point.mark;
        begin= this;
        end= this;
    }

    Point& operator=(const Point& other) {
        if(this == &other)    //先进行判定是否相同的对象
            return *this;
        this->x=other.x;
        this->y=other.y;
        this->mark= other.mark;
        begin= this;
        end= this;
        return *this;
    }

    double abs(){
        return sqrt(norm());
    }
    double norm(){
        return x*x+y*y;
    }
    Point operator + (Point p){
        return Point(x+p.x,y+p.y);
    }
    Point operator - (Point p){
        return Point(x-p.x,y-p.y);
    }
    Point operator * (double scale){
        return Point(scale*x,scale*y);
    }
    Point operator / (double scale){
        return Point(x/scale,y/scale);
    }
    bool operator == (const Point &p)const{
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
    bool operator != (const Point &p)const{
        return fabs(x-p.x)>EPS || fabs(y-p.y)>EPS;
    }
    bool operator < (const Point&p) const{
        return x!=p.x ? x<p.x : y<p.y;
    }
    void markPoint(){
        this->mark= true;
    }
    Point normalize(){
        double abs= this->abs();
        double x= this->x/abs;
        double y= this->y/abs;
        return Point(x,y);
    }
};
typedef Point Vector;



#endif //BIN_PACKING_POINT_H
